class IterationController < ApplicationController

    #  add
    def add
        @project = get_project(params[:id]);
        return unless params[:form_submitted];

	@iteration = Iteration.new(params[:iteration]);
	return unless @iteration.save();

	flash[:info_msg] = 'New iteration has been added';
	redirect_to(:controller => 'iteration', :action => 'list', :id => @iteration.project_fk);
    end

    # list
    def list
        @project = get_project(params[:id]);

        @iterations = @project.iterations;
    end

    # edit
    def edit
        @iteration = get_iteration(params[:id]);
        return unless params[:form_submitted];

        return unless @iteration.update_attributes(params[:iteration]);
	flash[:info_msg] = "Iteration modified";
        redirect_to(:controller => 'iteration', :action => 'show', :id => @iteration.iteration_id);
    end

    # show
    def show
        @iteration = get_iteration(params[:id]);
    end

end
